package com.woniuxy.buyer.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniuxy.buyer.entity.UserPoints;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * 用户积分Mapper
 */
@Mapper
public interface UserPointsMapper extends BaseMapper<UserPoints> {

    /**
     * 根据用户ID查询积分信息
     */
    @Select("SELECT up.*, u.nickname as username " +
            "FROM user_points up " +
            "LEFT JOIN users u ON up.user_id = u.id " +
            "WHERE up.user_id = #{userId}")
    UserPoints selectByUserId(Long userId);
}
